/**
 * CopyRight © 2012 USTC SINOVATE SOFTWARE CO.LTD All Rights Reserved.
 */

package com.cmcc.zysoft.infocollection.service;

import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.cmcc.zysoft.infocollection.dao.UserRolePcDao;
import com.cmcc.zysoft.infocollection.model.UserRole;
import com.starit.common.dao.hibernate.HibernateBaseDao;
import com.starit.common.dao.service.BaseServiceImpl;

/**
 * @author 袁凤建
 * <br />邮箱: yuan.fengjian@ustcinfo.com
 * <br />描述: UserRolePcService.java
 * <br />版本: 1.0.0
 * <br />日期: 2013-9-25 下午1:29:03
 * <br />CopyRight © 2012 USTC SINOVATE SOFTWARE CO.LTD All Rights Reserved.
 */

@Service
public class UserRolePcService extends BaseServiceImpl<UserRole, String> {

	@Resource
	private UserRolePcDao userRolePcDao;
	
	@Override
	public HibernateBaseDao<UserRole, String> getHibernateBaseDao() {
		return this.userRolePcDao;
	}
	
	/**
	 * 添加用户与角色的关联关系.
	 * @param userId 用户ID
	 * @param roleId 角色ID
	 * @return String
	 */
	@Transactional
	public String addUserRole(String userId, String roleId) {
		UserRole userRole = new UserRole();
		userRole.setUserId(userId);
		userRole.setRoleId(roleId);
		return this.userRolePcDao.save(userRole);
	}
}